package com.osce.score.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csce.domain.entity.score.ScoreExModelTime;
import com.doudou.core.container.ListUtil;
import com.osce.interfaces.score.IScoreExModelTimeService;
import com.osce.score.mapper.ScoreExModelTimeMapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 考试模版时间分段表Service业务层处理
 *
 * @author zzx
 * @since 2023-08-22
 */
@Service
public class ScoreExModelTimeServiceImpl extends ServiceImpl<ScoreExModelTimeMapper, ScoreExModelTime> implements IScoreExModelTimeService {


    /**
     * 查询考试模版时间分段表
     *
     * @param id 考试模版时间分段表主键
     * @return 考试模版时间分段表
     */
    @Override
    public ScoreExModelTime selectScoreExModelTimeById(Long id) {
        return baseMapper.selectScoreExModelTimeById(id);
    }

    /**
     * 查询考试模版时间分段表列表
     *
     * @param scoreExModelTime 考试模版时间分段表
     * @return 考试模版时间分段表
     */
    @Override
    public List<ScoreExModelTime> selectScoreExModelTimeList(ScoreExModelTime scoreExModelTime) {
        return baseMapper.selectScoreExModelTimeList(scoreExModelTime);
    }

    /**
     * 新增考试模版时间分段表
     *
     * @param scoreExModelTime 考试模版时间分段表
     * @return 结果
     */
    @Override
    public int insertScoreExModelTime(ScoreExModelTime scoreExModelTime) {
        return baseMapper.insertScoreExModelTime(scoreExModelTime);
    }

    /**
     * 修改考试模版时间分段表
     *
     * @param scoreExModelTime 考试模版时间分段表
     * @return 结果
     */
    @Override
    public int updateScoreExModelTime(ScoreExModelTime scoreExModelTime) {
        return baseMapper.updateScoreExModelTime(scoreExModelTime);
    }

    /**
     * 批量删除考试模版时间分段表
     *
     * @param ids 需要删除的考试模版时间分段表主键
     * @return 结果
     */
    @Override
    public int deleteScoreExModelTimeByIds(Long[] ids) {
        return baseMapper.deleteScoreExModelTimeByIds(ids);
    }

    /**
     * 删除考试模版时间分段表信息
     *
     * @param id 考试模版时间分段表主键
     * @return 结果
     */
    @Override
    public int deleteScoreExModelTimeById(Long id) {
        return baseMapper.deleteScoreExModelTimeById(id);
    }

    @Override
    public int deleteScoreExModelTimeByModelIds(Long[] ids) {
        return baseMapper.deleteScoreExModelTimeByModelIds(ids);
    }

    @Override
    public int batchScoreExModelTime(List<ScoreExModelTime> scoreExModelTimeList, Long modelId) {
        if (ListUtil.isEmpty(scoreExModelTimeList)) {
            return 0;
        }
        scoreExModelTimeList = scoreExModelTimeList.stream().peek(t -> t.setModelId(modelId)).collect(Collectors.toList());
        return baseMapper.batchScoreExModelTime(scoreExModelTimeList);
    }

    @Override
    public int deleteScoreExModelTimeByModelId(Long id) {
        return baseMapper.deleteScoreExModelTimeByModelId(id);
    }
}
